Welcome Guest, you are in: Login
Plus500US Futures Technologies

Page History: Connecting the API

Compare Page Revisions



« Older Revision - Back to Page History - Newer Revision »


Page Revision: 2012/01/21 17:57


To access the API from your application you need to add a reference to the T4API.20.dll and T4Definitions.20.dll files located in the c:\Program Files\CTS\T4ClientSim\bin\ folder to your project.


The namespace that contains all the API objects is T4.API. Most enumerations are defined in the T4 namespace:



' Import the T4 definitions namespace.
Imports T4

' Import the API namespace.
Imports T4.API


In order for your application to connect and login to the system you must create and hold a reference to a T4.API.Host object. Connection status and login responses are raised as events from this host object.



' Reference to the main api host object.
Private WithEvents moAPI As Host

To connect to the system you simply create the Host object:



' Initialise the api when the application starts.
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

' Create the api host object.
moAPI = New Host("", Host.ServerType.Simulator, "T4Example", "112A04B0-5AAF-42F4-994E-FA7CB959C60B", "cfc", "T4Example", "t4example")

End Sub

The parameters to the Host constructor are listed here.


The API will not connect immediately, instead it will create and return the Host object and then raise events following connection and login. The Connected and Disconnected events are raised to signal changes in the connection status:





' Event raised when the api has connected to a server.
Private Sub moAPI_Connected() Handles moAPI.Connected

Trace.WriteLine("Connected")

End Sub

' Event raised then the api has disconnected from a server.
Private Sub moAPI_Disconnected(ByVal psReason As String) Handles moAPI.Disconnected

Trace.WriteLine("Disconnected")

End Sub

These events are for notification only, following a Disconnected event the API will automatically keep trying to reconnect. You do not need to recreate the API to have it connect again. You can also check the IsConnected property of the Host object to check the connection state.

Note: Do not attempt to send messages (e.g. request market data, submit orders etc) between receiving the Connected event and before you receive the LoginSuccess event. Messages sent will either be ignored or cause the connection to be terminated. This applies also following a disconnect and reconnect.

Once the API has connected it will try to login automatically, the LoginSuccess and LoginFailure messages are raised with the result:

Trade how you want, where you want

T4.Support@plus500.com (312) 939 0164

2 Pierce Pl, Suite 200, Itasca, IL 60143

© 2009-2025 Plus500US Futures Technologies LLC All rights reserved.